package com.example.zxk.myapplication;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by zxk on 2017/9/11.
 */

public class RecylerAdapter extends RecyclerView.Adapter<RecylerAdapter.Holder> {


    private Context context;

    public RecylerAdapter(Context context) {
        this.context = context;
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        Holder holder = new Holder(LayoutInflater.from(context).inflate(R.layout.item_recyler, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {

        holder.tv.setText(position + 1 + "");
    }

    @Override
    public int getItemCount() {
        return 14;
    }

    class Holder extends RecyclerView.ViewHolder{

        TextView tv;
        public Holder(View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv);
        }
    }
}
